<template>
  <div class="fixed" v-dialogDrag>
    <div class="content el-dialog"
         style="padding:0">
      <div class="msgTop el-dialog__header">
        <span>差错标记</span>
        <i class="el-icon-close fr"
           style="cursor:pointer;line-height:40px;font-size:13px;"
           @click="cancelTransfer"></i>
      </div>
      <el-form :model="ruleForm"
               ref="ruleForm"
               class="demo-ruleForm"
               :rules="rules"
               style="padding:20px 20px 0 20px"
               label-width="100px">
        <!-- <el-form-item label="填写意见:" label-width="60px" prop="menuDesc">
          <el-input
            type="textarea"
            v-model="ruleForm.menuDesc"
            style="width:500px"
            :autosize="{ minRows: 3}"
          ></el-input>
        </el-form-item>-->
        <el-form-item label="差错等级"
                      prop="region"
                      label-width="100px">
          <el-select v-model="ruleForm.region"
                     placeholder="请选择差错等级"
                     style="width:80%">
            <el-option v-for="(item,index) in list"
                       :key="index"
                       :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label-width="10px"
                      class="center">
          <el-button @click="submitForm('ruleForm')"
                     type="button"
                     class="el-button el-button--primary el-button--medium h30Btn ">确定</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { workOrderLogAdd } from '@/api/WorkOrderUrgeController'
export default {
  data () {
    return {
      ruleForm: {
        region: ''
      },
      list: [{ label: '普通工单差错', value: '普通工单差错' }, { label: '重大工单差错', value: '重大工单差错' }],
      rules: {
        region: [
          { required: true, message: '请选择差错等级', trigger: 'change' }
        ]
      },
      workOrderIdList: ''
    }
  },
  mounted () {
  },
  methods: {
    cancelTransfer () {
      this.$emit('changeShow', false)
    },
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.workOrderIdList = this.$store.state.orderDetailsId
          let params = {
            content: this.ruleForm.region,
            logType: '5', // 是否有责6
            workOrderId: this.workOrderIdList,
            logCreaterId: this.$store.state.userId,
            // relationOrg: sessionStorage.getItem('institution')
          }
          workOrderLogAdd(params).then(res => {
            if (res.data.retCode === 200) {
              this.$message({
                type: 'success',
                message: res.data.msg
              })
              this.$emit('changeShow', false)
            } else {
              this.$message({
                type: 'error',
                message: res.data.msg
              })
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
.center {
  text-align: center;
  font-size: 13px;
}

.paging-foot {
  padding: 10px 0;
}

</style>
